/**
 * @description 交易所质押式回购
 * @author chenyan
 */

import { connect } from 'dva';
import React, { PureComponent } from 'react';
import { Spin } from 'antd';
import { SecondHeaderC } from '../../../comps';
import BaseInfoC from '../../InvestmentManage/BuybackOrder/exchangePledge/baseInfoC';
class BuyBackOrderExchange extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {
      businessKey: undefined,
      timeStamp: undefined,
      detailData: {},
    };
  }

  componentDidMount() {}

  UNSAFE_componentWillReceiveProps(nextProps) {
    if (this.state.timeStamp !== nextProps.timeStamp) {
      this.setState(
        {
          businessKey: nextProps.businessKey,
          timeStamp: nextProps.timeStamp,
        },
        () => {
          this.queryDetail();
        },
      );
    }
  }
  //查询质押式回购指令基本信息
  queryDetail = () => {
    this.props.dispatch({
      type: 'exchangePledgeM/queryBaseInfo',
      payload: {
        id: this.state.businessKey,
      },
      callback: (data) => {
        this.setState({
          detailData: data || {},
        });
      },
    });
  };

  render() {
    const { loading } = this.props;
    return (
      <Spin spinning={loading.effects['creditSettingM/getCreditDetail'] == true}>
        <SecondHeaderC title={'指令信息'} />
        <BaseInfoC type={3} info={this.state.detailData} />
      </Spin>
    );
  }
}

export default connect(({ exchangePledgeM, loading }) => ({ exchangePledgeM, loading }))(BuyBackOrderExchange);
